﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Faculty
{
    class Department
    {
        string name;
        string head;
        List<Group> groups;

        public Department(string name, string head)
        {
            this.name = name;
            this.head = head;
            groups = new List<Group>();
        }

        public void AddGroup(Group group)
        {
            groups.Add(group);
        }

        public void ShowInfo()
        {
            
            Console.WriteLine(this);
            Console.WriteLine();
            foreach (var group in groups)
            {
                group.ShowInfo();
            }
        }

        public bool ShowStudentBetterThanCriteium(string groupName, double criterium)
        {
            foreach(var group in groups)
            {
                if (group.GetGroupName() == groupName)
                {
                    group.ShowStudentBetterThanCriteium(criterium);
                    return true;
                }
            }
            return false;
        }

        public bool ShowStudentWorseThanCriteium(string groupName, double criterium)
        {
            foreach (var group in groups)
            {
                if (group.GetGroupName() == groupName)
                {
                    group.ShowStudentWorseThanCriteium(criterium);
                    return true;
                }
            }
            return false;
        }

        //выведет всех студентов с "долгами" (отметками 2 балла и менее)
        public bool ShowStudentWithDebts(string groupName)
        {
            foreach (var group in groups)
            {
                if (group.GetGroupName() == groupName)
                {
                    group.ShowStudentWithDebts();
                    return true;
                }
            }
            return false;
        }

        public void ShowAllStudentBetterThanCriteium(double criterium)
        {
            foreach (var group in groups)
                    group.ShowStudentBetterThanCriteium(criterium);
        }

        public void ShowAllStudentWorseThanCriteium(double criterium)
        {
            foreach (var group in groups)
                    group.ShowStudentWorseThanCriteium(criterium);
        }


        public void ShowAllStudentWithDebts()
        {
            foreach (var group in groups)
            {
                    group.ShowStudentWithDebts();
            }
        }

        public string GetName()
        {
            return name;
        }

        public override string ToString()
        {
            return String.Format("Кафедра \"{0}\". Зав. Кафедрой {1}", name, head);
        }
    }
}
